package array;

import java.util.Scanner;

public class sum {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        int s = 0;
        for (int i = 0; i < n; i++) {
            s += scanner.nextInt();
            arr[i] = s;
        }
        while (scanner.hasNext()){
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            System.out.println(cul(a, b, arr));
        }
    }
    public static int cul(int a, int b, int[] arr){
        if (a == 0){
            return arr[b];
        }
        return arr[b] - arr[a - 1];
    }
}
